import { createRouter, createWebHashHistory } from "vue-router";
import Layout from "@/views/layout.vue";

const routes = [
  {
    path: "/login",
    component: () => import("@/views/login/index.vue"),
  },
  {
    path: "/",
    component: Layout,
    children: [
      {
        path: "", // 以/开头的是绝对写法，不以/开头的是相对写法 父路由路径/自身路径
        component: () => import("@/views/home/index.vue"),
      },
      {
        // 1级菜单
        path: "category/:id", //  动态路由id后面加？则表示id参数可有可无
        component: () => import("@/views/category/index.vue"),
      },
      {
        // 2级菜单
        path: "category/sub/:id",
        component: () => import("@/views/category/sub.vue"),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
